﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Tree/jsTree/style.min.css" rel="stylesheet" />
    <title>Parities</title>
    <style type="text/css">
        .modal-header {
            padding: 6px 5px;
            border-bottom: none;
            background: #d8d8d2;
            text-align: center;
            color: #000;
        }

        .modal-content {
            padding: 6px;
        }

        .modal-body {
            padding: 0 25px;
        }

        .btn {
            background: #d8d8d2;
            margin-top: 5px;
        }

            .btn:hover {
                background: #5190f8;
            }

        .container {
            width: 100%;
        }
        .panel-heading {
            font-size: 16px;
            text-align: center;
            background-color:#d8d8d2;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="panel-heading">
                <span>系统汇率</span>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <button class="btn  glyphicon glyphicon-off" type="button" id="Close"> 关闭</button>
                <button class="btn  glyphicon glyphicon-refresh" type="button" id="Refresh"> 刷新</button>
                <button class="btn  glyphicon glyphicon-plus" type="button" id="Insert"> 新增</button>
                <button class="btn  glyphicon glyphicon-pencil" type="button" id="Update"> 编辑</button>
                <button class="btn  glyphicon glyphicon-remove" type="button" id="Delete"> 删除</button>
                <button class="btn  glyphicon glyphicon-print" type="button" id="Print"> 打印</button>
                <button class="btn  glyphicon glyphicon-paste" type="button" id="ExportToExcel"> 导出</button>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12" style="float:right">
                <div class="panel-body">
                    <div class="row examineeInfor">
                        <table id="parities" class="table table-condensed" style="width:100%">
                            <thead>
                                <tr>
                                    <th w_index="ParitiesID" w_check="true">选择</th>
                                    <th w_num="total_line">序号</th>
                                    <th w_index="Currency" width="">交易币</th>
                                    <th w_index="BasicCurrency" width="">基本币</th>
                                    <th w_index="ConversionRate" width="">兑换率</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        @*新增模态框*@
        <div class="modal  bs-example-modal-sm" id="modInsertExaminee">
            <div class="modal-content" style="width:400px;height:210px;margin-left:600px;">
                <div class="modal-header">
                    <h5 class="modal-title glyphicon glyphicon-plus"> 系统汇率</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" id="formInsert" action="/Basics/Basics/InsertParities" method="post">
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">交易币:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="Currency" maxlength="5" onkeyup="value = value.replace(/[^A-Z]+$/,'')" />
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">基本币:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="BasicCurrency" maxlength="5" onkeyup="value = value.replace(/[^A-Z]+$/,'')" /> 
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">兑换率:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="ConversionRate" />
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-11 col-md-8 col-sm-10 col-lg-offset-2">
                                <button class="btn glyphicon glyphicon-repeat" type="reset"> 重置</button>
                                <button class="btn glyphicon glyphicon-ok" type="button" id="SaveParities"> 保存</button>
                                <button class="btn glyphicon glyphicon-remove" data-dismiss="modal"> 关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        @*修改模态框*@
        <div class="modal  bs-example-modal-sm" id="modUpdateExaminee">
            <div class="modal-content" style="width:400px;height:210px;margin-left:600px;">
                <div class="modal-header">
                    <h5 class="modal-title glyphicon glyphicon-pencil"> 系统汇率</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form" id="formUpdate" action="/Basics/Basics/UpdateParities" method="post">
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">交易币:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="Currency" maxlength="5" onkeyup="value = value.replace(/[^A-Z]+$/,'')" />
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">基本币:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="BasicCurrency" maxlength="5" onkeyup="value = value.replace(/[^A-Z]+$/,'')" />
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <div class="col-lg-4 col-md-3 col-sm-2 text-right">
                                    <label class="control-label">兑换率:</label>
                                </div>
                                <div class="col-lg-8 col-md-5 col-sm-5">
                                    <input type="text" class="form-control" id="" name="ConversionRate" />
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top:5px;">
                            <div class="col-lg-11 col-md-8 col-sm-10 col-lg-offset-2">
                                <button class="btn glyphicon glyphicon-repeat" type="reset"> 重置</button>
                                <button class="btn glyphicon glyphicon-ok" type="button" id="UpdateSave"> 保存</button>
                                <button class="btn glyphicon glyphicon-remove" data-dismiss="modal"> 关闭</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script src="~/Content/Tree/jquery.min.js"></script>
    <link href="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.css" rel="stylesheet" />
    <script src="~/Content/bootstrap-3.3.7-dist/js/jquery-2.0.3.min.js"></script>
    <script src="~/Content/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/merged/bsgrid.all.min.js"></script>
    <script src="~/Content/jquery.bsgrid-1.37/builds/js/lang/grid.zh-CN.min.js"></script>
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/js/customfunction.js"></script>
    <script src="~/Content/js/combobox.js"></script>
    <script src="~/Content/layer/layer.js"></script>
    <script src="~/Content/Tree/Tree.js"></script>
    <script src="~/Content/Tree/jstree.min.js"></script>
    <script>
        var tabparities;
        //查询系统汇率表
        tabparities = $.fn.bsgrid.init('parities', {
            url: 'selectParities',
            autoLoad: true,//自动加载数据
            stripeRows: true,//隔行变色
            rowHoverColor: true,//划过行变色
            displayBlankRows: true,//是否显示空白行，默认值false
            rowSelectedColor: true,//是否显示选中行背景色
            pageSize: 10,//默认页面大小
            pageSizeSelect: true,//是否选择分页页数下拉框
            pagingLittleToolbar: true,//精简的图标按钮分页工具条
            //事件
            event: {
                customRowEvents: {//自定义行事件
                    //(record行记录值,rowIndex行索引值,trObj:tr目标,options选择的东西)
                    click: function (record, rowIndex, trObj, options) {
                        Check("#parities tr", rowIndex + 1);
                    }
                }
            }
        });
        //关闭
        $("#Close").click(function () {
            window.location.href = "/Main/index";
        })
        //刷新
        $("#Refresh").click(function () {
            location.reload();
        })
        //新增
        $("#Insert").click(function () {
            $('#formInsert').resetForm();
            $("#modInsertExaminee").modal("show");
        });
        $("#SaveParities").click(function () {
            var Currency = $('#formInsert [name="Currency"]').val();
            var BasicCurrency = $('#formInsert [name="BasicCurrency"]').val();
            var ConversionRate = $('#formInsert [name="ConversionRate"]').val();
            //判断一些必填项的数据是否为空
            if (Currency != '') {
                if (BasicCurrency != '') {
                    if (ConversionRate != '') {
                        //显示 加载层（是第三方对话框的属性）
                        var layerIndex = layer.load(0);
                        //ajaxSubmit()提交表单:我们直接通过form提交的话， 提交后当前页面跳转到form的action所指向的页面。
                        //然而，很多时候我们并不希望提交表单后页面跳转，那么，我们就可以使用ajaxSubmit(obj)来提交数据
                        //ajaxSubmit(obj)方法是jQuery的一个插件jquery.form.js里面的方法，所以使用此方法需要先引入这个插件
                        $("#formInsert").ajaxSubmit(function (msg) {
                            layer.close(layerIndex);//关闭加载层
                            if (msg == "数据新增成功！") {
                                tabparities.search();//调用多条件查询方法：起到刷新表格的作用
                                $("#modInsertExaminee").modal("hide");//关闭 modal
                                layer.msg(msg, { icon: 1 });
                            }
                            else {
                                layer.msg(msg, { icon: 0 });
                            }
                        });
                    }
                    else {
                        layer.msg("兑换率不能为空！", { icon: 0 });
                    }
                }
                else {
                    layer.msg("基本币不能为空！", { icon: 0 });
                }
            }
            else {
                layer.msg("交易币不能为空！", { icon: 0 });
            }
        })
        //编辑
        $("#Update").click(function () {
            var check = $("#parities input:checked");
            if (check.length == 0) {
                //0警告；1成功；2失败；3问号；4锁；5难过表情；6微笑表情
                layer.msg("请选择一条信息!", { icon: 0 });
            }
            if (check.length > 1) {
                layer.msg("只能选择一条信息!", { icon: 0 });
            }
            if (check.length == 1) {
                $.post("/Basics/Basics/SelectParitiesById", { ParitiesID: check[0].value }, function (data) {
                    loadDatatoForm("formUpdate", data);
                })
                $("#modUpdateExaminee").modal("show");
            }
        })
        $("#UpdateSave").click(function () {
            var Currency = $('#formUpdate [name="Currency"]').val();
            var BasicCurrency = $('#formUpdate [name="BasicCurrency"]').val();
            var ConversionRate = $('#formUpdate [name="ConversionRate"]').val();
            //判断一些必填项的数据是否为空
            if (Currency != '') {
                if (BasicCurrency != '') {
                    if (ConversionRate != '') {
                        var layerIndex = layer.load(0);
                        $("#formUpdate").attr("action", "/Basics/Basics/UpdateParities?ParitiesID=" + $("#parities input:checked")[0].value);
                        $("#formUpdate").ajaxSubmit(function (msg) {
                            layer.close(layerIndex);
                            if (msg == "修改成功！") {
                                tabparities.search();
                                $("#modUpdateExaminee").modal("hide");
                                layer.msg(msg, { icon: 1});
                            }
                            else {
                                layer.msg(msg, { icon: 0 });
                            }
                        });
                    }
                    else {
                        layer.msg("兑换率不能为空！", { icon: 0 });
                    }
                }
                else {
                    layer.msg("基本币不能为空！", { icon: 0 });
                }
            }
            else {
                layer.msg("交易币不能为空！", { icon: 0 });
            }
        });
        //删除
        $("#Delete").click(function () {
            var check = $("#parities input:checked");
            if (check.length > 0) {
                layer.confirm("确认删除数据",
                    {
                        icon: 0,
                        btn: ['确认', '取消']
                    },
                    function (layerIndex) {
                        layer.close(layerIndex);
                        for (var i = 0; i < check.length; i++) {
                            var id = check[i].value;
                            $.ajax({
                                type: "get",
                                async: false,
                                url: "DelectParities?ParitiesID=" + id,
                                success: function (data) {
                                    if (data) {
                                        location.reload();
                                    } else {
                                        layer.alert("删除失败", { icon: 0, title: '提示' })
                                    }
                                }
                            })
                        }
                    });
            }
            else {
                layer.msg('请选择删除的数据', { icon: 0 });
            }
        });
        //excel导出
        $("#ExportToExcel").click(function () {
            var oldStr = tabparities.getPageCondition(tabparities.getCurPage());
            if (oldStr.indexOf) {
                layer.confirm("是否要导出当前的数据？", {
                    icon: 3,
                    btn: ['确定', '取消']
                }, function (layerIndex) {
                    layer.close(layerIndex);
                    window.open("ExportToExcelParities");
                })
            }
            else {
                layer.msg("预览是否是需要导出", { icon: 0, title: '提示' });
            }
        });
        //打印
        $("#Print").click(function () {
            window.open("PrintAchievementParities?");
        })
    </script>
</body>
</html>
